#pragma once

class ATL_NO_VTABLE CPanicButton:
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<CPanicButton, &CLSID_PanicButton>,
	public IConnectionPointContainerImpl<CPanicButton>,
	public CProxyDPanicButtonEvents<CPanicButton>,
	public IDispatchImpl<IPanicButton, &IID_IPanicButton, &LIBID_PanicButtonLib, 1, 0>,
	public BigRedButtonNotifications
{
public:

	DECLARE_REGISTRY_RESOURCEID( IDR_PANICBUTTON )

	BEGIN_COM_MAP( CPanicButton )
		COM_INTERFACE_ENTRY( IPanicButton )
		COM_INTERFACE_ENTRY( IDispatch )
		COM_INTERFACE_ENTRY( IConnectionPointContainer )
	END_COM_MAP( )

	BEGIN_CONNECTION_POINT_MAP( CPanicButton )
		CONNECTION_POINT_ENTRY( __uuidof( DPanicButtonEvents ) )
	END_CONNECTION_POINT_MAP( )

	DECLARE_PROTECT_FINAL_CONSTRUCT( )

public:

	CPanicButton( );
	virtual ~CPanicButton( );

	HRESULT FinalConstruct( );
	void FinalRelease( );

	//
	// IPanicButton
	//

public:

	STDMETHOD( OpenDevice )( void );
	STDMETHOD( CloseDevice )( void );

	STDMETHOD( get_RefreshRate )( int* pVal );
	STDMETHOD( put_RefreshRate )( int val );
	STDMETHOD( get_LidOpen )( VARIANT_BOOL* pVal );
	STDMETHOD( get_ButtonPressed )( VARIANT_BOOL* pVal );
	STDMETHOD( get_IsOpen )( VARIANT_BOOL* pVal );

	//
	// BigRedButtonNotifications
	//

public:

	virtual void BLidStateChange( bool lidOpen );
	virtual void BButtonStateChange( bool buttonPressed );

	//
	// Implementation
	//

private:

	BigRedButton* pImplementation;
	bool lidOpen;
	bool buttonPressed;

};

OBJECT_ENTRY_AUTO( __uuidof( PanicButton ), CPanicButton )
